import request from '@/utils/request'

export function fetchList(query) {
  return request({
    url: '/api/role/list',
    method: 'get',
    params: query
  })
}

export function exportRole() {
  return request({
    url: '/api/role/export',
    method: 'post',
    responseType: 'blob'
  })
}

export function fetchRole(id) {
  return request({
    url: '/api/role/detail',
    method: 'get',
    params: { id }
  })
}

export function createRole(data) {
  return request({
    url: '/api/role/create',
    method: 'post',
    data
  })
}

export function deleteRole(data) {
  return request({
    url: '/api/role/delete',
    method: 'post',
    data
  })
}

export function login(data) {
  return request({
    url: '/api/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/api/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/api/user/logout',
    method: 'post'
  })
}
